//获取错误
exports.getErr = (err = "server interval err", errCode = 500) => {
    return {
        code: errCode,
        msg: err,
        data: null
    }
}
//获取成功结果
exports.getResult = (result) => {
    return {
        code: 0,
        msg: "",
        data: result
    }
}

exports.asyncHandler = (handler) => {
    return async (req, res, next) => { //fun1
        try {
            const result = await handler(req, res, next)
            res.send(exports.getResult(result))
        } catch (error) {
            next(error)
        }
    }
}